Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@turf/sample

Package Overview
Dependencies
Maintainers
4
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/sample

turf sample module

  • 3.14.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
791K
increased by15.01%
Maintainers
4
Weekly downloads
 
Created

What is @turf/sample?

@turf/sample is a module within the Turf.js library, which is a collection of geospatial analysis tools written in JavaScript. The @turf/sample package specifically allows users to sample a specified number of points from a given set of features, such as polygons or lines, within a GeoJSON object.

What are @turf/sample's main functionalities?

Random Point Sampling

This feature allows you to randomly sample a specified number of points from a set of points. In this example, 100 random points are generated within the given bounding box, and then 10 points are sampled from these.

const turf = require('@turf/turf');
const sample = require('@turf/sample');

const points = turf.randomPoint(100, {bbox: [-180, -90, 180, 90]});
const sampledPoints = sample(points, 10);
console.log(sampledPoints);

Sampling from Polygons

This feature allows you to sample points from within a polygon. In this example, a polygon is defined, 100 random points are generated within the bounding box of the polygon, and then 10 points are sampled from these.

const turf = require('@turf/turf');
const sample = require('@turf/sample');

const polygon = turf.polygon([[
  [-5, 52], [-4, 52], [-4, 53], [-5, 53], [-5, 52]
]]);
const points = turf.randomPoint(100, {bbox: [-5, 52, -4, 53]});
const sampledPoints = sample(points, 10);
console.log(sampledPoints);

Other packages similar to @turf/sample

Keywords

FAQs

Package last updated on 22 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc